package 集合;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author chihb
 * @create-time 2024/7/1 21:05
 * @description
 */
public class Test {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("sss");
        list.add("hhh");
        list.add("eee");
        list.add("ddd");
        list.add("aaa");
        System.out.println("========普通for循环========");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("========增强for循环========");
        for(String i:list){
            System.out.println(i);
        }
        System.out.println("========迭代器循环========");
        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("========lambda的forEach循环========");
        list.forEach(System.out::println);
        String str1=new String("abc");
        String str2=new String("acD");
        System.out.println(str1.hashCode());
        System.out.println(str2.hashCode());
    }
}
